﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace Leo.Core.Gateway.Yarp
{
    /// <summary>
    /// Remark: 暂时没用,如果需要使用请以下文档说明
    /// <see cref="https://microsoft.github.io/reverse-proxy/articles/getting-started.html"/> 
    /// </summary>
    public static class YarpSupport
    {
        public static void AddYarp(this IServiceCollection services) 
        {
            // 添加反向代理
            services.AddReverseProxy()
                .LoadFromConfig(services.GetConfiguration().GetSection("ReverseProxy")); // 从配置的“ReverseProxy”部分初始化反向代理 
        }

        public static void UseYarp(this IApplicationBuilder builder) 
        {
            builder.UseEndpoints(endpoints =>
            {
                endpoints.MapReverseProxy();
            });
        }
    }
}
